import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-07-08
 * Time: 18:37
 */
public class test7 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            int[] cost = new int[n];
            for(int i=0;i<n;i++){
                cost[i] = in.nextInt();
            }
            int[] dp = new int[n+1];
            dp[0] = 0;
            dp[1] = 0;
            for(int i=2;i<=n;i++){
                dp[i] = Math.min(dp[i-2]+cost[i-2],dp[i-1]+cost[i-1]);
            }
            System.out.println(dp[n]);
        }
    }
}
